﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using ZXCompany.Models;
using ZXCompany.Models.Entity;
using System.Text;
using System.Collections.Generic;
using System.Web;

namespace ZXCompany.Controllers
{
    [ValidateInput(false)]
    [HandleError]
    public class AccountController : Controller
    {

        public IFormsAuthenticationService FormsService { get; set; }
        public IMembershipService MembershipService { get; set; }
        private DBUtil.Common comm = new DBUtil.Common();
        public Models.Service.ServiceFactory SerFac = new Models.Service.ServiceFactory();

        protected override void Initialize(RequestContext requestContext)
        {
            if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
            if (MembershipService == null) { MembershipService = new AccountMembershipService(); }

            base.Initialize(requestContext);
        }

        // **************************************
        // URL: /Account/LogOn
        // **************************************

        public ActionResult LogOn()
        {
            return View("Index");
        }
        
        public ActionResult LeftView()
        {
            return View("Left");
        }

        #region 公司介绍

        /// <summary>
        /// 公司介绍
        /// </summary>
        /// <returns></returns>
        public ActionResult CompanyInfo()
        {
            ZX_CompanyInfo info =SerFac.GetAccount().CinfoSelect();
            return View("CompanyInfo", info);
        }

        [HttpPost]
        public ActionResult CompanyInfo_Add(ZX_CompanyInfo Cinfo)
        {
            ZX_CompanyInfo info = new ZX_CompanyInfo();
            info.ID = Cinfo.ID;
            info.companyInfo = Cinfo.companyInfo;
            info.addUserID = Cinfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (Cinfo.ID > 0)
                SerFac.GetAccount().CinfoUpdate(info);
            else
            {
                SerFac.GetAccount().CinfoInsert(info);
                info = SerFac.GetAccount().CinfoSelect();
            }
            return View("CompanyInfo", info);

        //    addUserID { get; set; }
        ///// <summary>
        ///// 添加时间
        ///// </summary>
        //public string addTime { get; set; }
        ///// <summary>
        ///// 更新时间
        ///// </summary>
        //public string updateTime { get; set; }
            //SvrUser.UserInsert(user);
            //return View("ViewUserAdd", uadd);
        }

        #endregion

        #region 首页图片
        /// <summary>
        /// 首页图片表
        /// </summary>
        /// <returns></returns>
        public ActionResult HomePageImage()
        {
            IList<ZX_HomePageImage> Homelist;
            int hp_id = 0;
            ZX_HomePageImage HomePI = new ZX_HomePageImage();
            try
            {
                hp_id = Request.QueryString["hp_id"] == null ? 0 : Convert.ToInt32(Request.QueryString["hp_id"]);
                Homelist = SerFac.GetHomePageImageServie().GetHomePageImageById(hp_id);
                if (Homelist==null || Homelist.Count<1)
                {
                    HomePI.ID = 0;
                    HomePI.imageHref = "";
                    HomePI.imageUrl = "";
                    HomePI.sort = SerFac.GetAboutService().GetExpertTypeMaxId("ZX_HomePageImage", "sort");
                }
                else
                {
                    HomePI = Homelist[0];
                }
                string actionstr = Request.QueryString["action"] == null ? "" : Request.QueryString["action"].ToString();
                if (actionstr =="del")
                {
                    SerFac.GetHomePageImageServie().DeleteById(hp_id);
                }
            }
            catch (Exception)
            {}

            Homelist = SerFac.GetHomePageImageServie().GetHomePageImage();
            ViewData["Account_HPImage"] = Homelist;
            return View("HomePageImage",HomePI);
        }

        public ActionResult HomePageImage_Del(string action, int id)
        {
            IList<ZX_HomePageImage> Homelist = SerFac.GetHomePageImageServie().GetHomePageImage();
            ViewData["Account_HPImage"] = Homelist;
            int hp_id = 0;
            ZX_HomePageImage HomePI = new ZX_HomePageImage();
            try
            {
                hp_id = Request.QueryString["hp_id"] == null ? 0 : Convert.ToInt32(Request.QueryString["hp_id"]);
                Homelist = SerFac.GetHomePageImageServie().GetHomePageImageById(hp_id);
                if (Homelist == null || Homelist.Count < 1)
                {
                    HomePI.ID = 0;
                    HomePI.imageHref = "";
                    HomePI.imageUrl = "";
                    HomePI.sort = 0;
                }
                else
                {
                    HomePI = Homelist[0];
                }
            }
            catch (Exception)
            { }

            return View("HomePageImage", HomePI);
        }

        /// <summary>
        /// 首页图片表 添加编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult HomePageImage_Edit(ZX_HomePageImage FromInfo)
        {
            ZX_HomePageImage HomePI = new ZX_HomePageImage();
            HomePI.ID = FromInfo.ID;

            string Pic_Path = "";
            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file = Request.Files[0];
                Pic_Path = comm.UpLoadPic(file);  //UpLoadPic(file, out phWidth, out phHeight);
            }
            HomePI.imageUrl = Pic_Path; //FromInfo.imageUrl;
            HomePI.imageHref = FromInfo.imageHref==null? "":FromInfo.imageHref;
            HomePI.sort = FromInfo.sort == null ? 10 : FromInfo.sort;
            HomePI.addUserID = FromInfo.addUserID;
            HomePI.addTime = DateTime.Now.ToString();
            HomePI.updateTime = DateTime.Now.ToString();
            SerFac.GetHomePageImageServie().SaveHomePageImage(HomePI);
            return HomePageImage();
        }
        #endregion

        #region 经营理念        
        /// <summary>
        /// 经营理念
        /// </summary>
        /// <returns></returns>
        public ActionResult RunIdea()
        {
            ZX_RunIdea runidea = SerFac.GetAccount().RunIdeaSelect();
            return View("RunIdea",runidea);
        }
        [HttpPost]
        public ActionResult RunIdea_Edit(ZX_RunIdea FromInfo)
        {
            ZX_RunIdea info = new ZX_RunIdea();
            info.ID = FromInfo.ID;
            info.runIdea = FromInfo.runIdea;
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAccount().RunIdeaUpdate(info);
            else
            {
                SerFac.GetAccount().RunIdeaInsert(info);
                info = SerFac.GetAccount().RunIdeaSelect();
            }
            //Content("<script>alert('保存成功！');window.location='" + VirtualPath.getVirtualPath() + "/Login';</script>");
            return View("RunIdea", info);

        }
        #endregion

        #region 总经理致辞        
        /// <summary>
        /// 总经理致辞
        /// </summary>
        /// <returns></returns>
        public ActionResult ManagerSpeak()
        {
            ZX_ManagerSpeak runidea = SerFac.GetAccount().MSpeakSelect();
            return View("ManagerSpeak", runidea);
        }
        [HttpPost]
        public ActionResult MSpeak_Edit(ZX_ManagerSpeak FromInfo)
        {
            ZX_ManagerSpeak info = new ZX_ManagerSpeak();
            info.ID = FromInfo.ID;
            info.speak = FromInfo.speak;
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAccount().MSpeakUpdate(info);
            else
            {
                SerFac.GetAccount().MSpeakInsert(info);
                info = SerFac.GetAccount().MSpeakSelect();
            }
            return View("ManagerSpeak", info);
        }
        #endregion

        #region 专家团队分类        
        /// <summary>
        /// 专家团队分类
        /// </summary>
        /// <returns></returns>
        public ActionResult ExpertType()
        {
            IList<ZX_ExpertType> Homelist;
            int hp_id = 0;
            ZX_ExpertType HomePI = new ZX_ExpertType();
            try
            {
                hp_id = Request.QueryString["hp_id"] == null ? 0 : Convert.ToInt32(Request.QueryString["hp_id"]);
                Homelist = SerFac.GetAboutService().GetExpertTypeById(hp_id);
                if (Homelist == null || Homelist.Count < 1)
                {
                    HomePI.ID = 0;
                    HomePI.sort = SerFac.GetAboutService().GetExpertTypeMaxId();
                    HomePI.etype = "";
                    HomePI.addUserID = 0;
                    HomePI.addTime ="";
                    HomePI.updateTime = "";
                    HomePI.Lexpert = new List<ZX_ExpertInfo>();
                }
                else
                {
                    HomePI = Homelist[0];
                }
                string actionstr = Request.QueryString["action"] == null ? "" : Request.QueryString["action"].ToString();
                if (actionstr == "del")
                {
                    SerFac.GetAboutService().DeleteExpertTypeById(hp_id);
                }
            }
            catch (Exception)
            { }
            
            Homelist = SerFac.GetAboutService().GetExpertType();
            ViewData["Account_ExpertType"] = Homelist;
            return View("ExpertType", HomePI);
        }

        /// <summary>
        /// 专家团队分类 添加编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult ExpertType_Edit(ZX_ExpertType FromInfo)
        {
            ZX_ExpertType HomePI = new ZX_ExpertType();
            HomePI.ID = FromInfo.ID;
            HomePI.etype = FromInfo.etype;
            HomePI.sort = FromInfo.sort;
            HomePI.addUserID = FromInfo.addUserID;
            HomePI.addTime = DateTime.Now.ToString();
            HomePI.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID>0)
                SerFac.GetAboutService().UpdateExpertType(HomePI);
            else
                SerFac.GetAboutService().InsertExpertType(HomePI);
            return ExpertType();
        }

        #endregion

        #region 专家团队信息        
        /// <summary>
        /// 专家团队信息
        /// </summary>
        /// <returns></returns>
        public ActionResult ExpertInfo()
        {
            IList<ZX_ExpertInfo> Homelist;
            int hp_id = 0;
            ZX_ExpertInfo HomePI = new ZX_ExpertInfo();
            try
            {
                string actionstr = Request.QueryString["action"] == null ? "" : Request.QueryString["action"].ToString();
                hp_id = Request.QueryString["hp_id"] == null ? 0 : Convert.ToInt32(Request.QueryString["hp_id"]);
                if (actionstr == "del")
                {
                    SerFac.GetAboutService().DeleteExpertInfoById(hp_id);
                }
                else if (actionstr != "")
                {
                    HomePI = SerFac.GetAboutService().GetExpertInfoById(hp_id);
                    if (HomePI == null)
                    {
                        HomePI = new ZX_ExpertInfo();
                        HomePI.ID = 0;
                        HomePI.sort = SerFac.GetAboutService().GetExpertTypeMaxId("ZX_ExpertInfo", "sort");
                        HomePI.expertDetail = "";
                        HomePI.expertName = "";
                        HomePI.expertPostion = "";
                        HomePI.imageUrl = "";
                        HomePI.typeID = 0;
                        HomePI.addUserID = 0;
                        HomePI.addTime = "";
                        HomePI.updateTime = "";
                    }
                }
            }
            catch (Exception)
            { }

            Homelist = SerFac.GetAboutService().GetExpertInfo();
            ViewData["Account_ExpertInfo"] = Homelist;
            //专家分类信息
            IList<ZX_ExpertType> Typelist = SerFac.GetAboutService().GetExpertType();
            ViewData["Account_ExpertType"] = Typelist;
            return View("ExpertInfo", HomePI);
        }

        /// <summary>
        /// 专家团队分类 添加编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult ExpertInfo_Edit(ZX_ExpertInfo FromInfo)
        {
            ZX_ExpertInfo HomePI = new ZX_ExpertInfo();
            HomePI.ID = FromInfo.ID;
            HomePI.expertDetail = FromInfo.expertDetail;
            HomePI.expertName = FromInfo.expertName;
            HomePI.expertPostion = FromInfo.expertPostion;
            string Pic_Path = "";
            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file = Request.Files[0];
                Pic_Path = comm.UpLoadPic(file);
            }
            HomePI.imageUrl = Pic_Path;
            HomePI.typeID = FromInfo.typeID;
            HomePI.sort = FromInfo.sort;
            HomePI.addUserID = FromInfo.addUserID;
            HomePI.addTime = DateTime.Now.ToString();
            HomePI.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAboutService().UpdateExpertInfo(HomePI);
            else
                SerFac.GetAboutService().InsertExpertInfo(HomePI);
            return ExpertInfo();
        }

        #endregion
        
        #region 差异化
        
        /// <summary>
        /// 差异化
        /// </summary>
        /// <returns></returns>
        public ActionResult Different()
        {
            ZX_Different zf = SerFac.GetSolutionService().GetDifferent();
            return View("Different",zf);
        }
        [HttpPost]
        public ActionResult Different_Edit(ZX_Different FromInfo)
        {
            ZX_Different info = new ZX_Different();
            info.ID = FromInfo.ID;
            info.differentinfo = FromInfo.differentinfo;
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetSolutionService().DifUpdate(info);
            else
            {
                SerFac.GetSolutionService().DifInsert(info);
                info = SerFac.GetSolutionService().GetDifferent();
            }
            return View("Different", info);
        }
        #endregion

        #region 整体image
        /// <summary>
        /// 整体image
        /// </summary>
        /// <returns></returns>
        public ActionResult WholeInfo()
        {
            ZX_WholeInfo wholeinfo = SerFac.GetAccount().WholeInfoSelect();
            return View("WholeInfo", wholeinfo);
        }
        [HttpPost]
        public ActionResult WholeInfo_Edit(ZX_WholeInfo FromInfo)
        {
            ZX_WholeInfo info = new ZX_WholeInfo();
            info.ID = FromInfo.ID;
            info.detailInfo = FromInfo.detailInfo;
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAccount().WholeInfoUpdate(info);
            else
            {
                SerFac.GetAccount().WholeInfoInsert(info);
                info = SerFac.GetAccount().WholeInfoSelect();
            }
            return View("WholeInfo", info);
        }
        #endregion

        #region 整体战略
        /// <summary>
        /// 整体战略
        /// </summary>
        /// <returns></returns>
        public ActionResult WholeInfoStrategy()
        {
            ZX_WholeInfoStrategy whstrategy = SerFac.GetAccount().WholeInfoStrategySelect();
            return View("WholeInfoStrategy", whstrategy);
        }
        [HttpPost]
        public ActionResult WholeInfoStrategy_Edit(ZX_WholeInfoStrategy FromInfo)
        {
            ZX_WholeInfoStrategy info = new ZX_WholeInfoStrategy();
            info.ID = FromInfo.ID;
            info.detailInfo = FromInfo.detailInfo;
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAccount().WholeInfoStrategyUpdate(info);
            else
            {
                SerFac.GetAccount().WholeInfoStrategyInsert(info);
                info = SerFac.GetAccount().WholeInfoStrategySelect();
            }
            return View("WholeInfoStrategy", info);
        }
        #endregion

        #region 精益生产
        /// <summary>
        /// 精益生产
        /// </summary>
        /// <returns></returns>
        public ActionResult Product()
        {
            ZX_Product pro = SerFac.GetAccount().ProductSelect();
            return View("Product",pro);
        }
        [HttpPost]
        public ActionResult Product_Edit(ZX_Product FromInfo)
        {
            ZX_Product info = new ZX_Product();
            info.ID = FromInfo.ID;
            info.detailInfo = FromInfo.detailInfo;
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAccount().ProductUpdate(info);
            else
            {
                SerFac.GetAccount().ProductInsert(info);
                info = SerFac.GetAccount().ProductSelect();
            }
            return View("Product", info);
        }

        #endregion

        #region 品质改善
        /// <summary>
        /// 品质改善
        /// </summary>
        /// <returns></returns>
        public ActionResult QualityChange()
        {
            ZX_QualityChange qc = SerFac.GetAccount().QualityChangeSelect();
            return View("QualityChange",qc);
        }
        [HttpPost]
        public ActionResult QualityChange_Edit(ZX_QualityChange FromInfo)
        {
            ZX_QualityChange info = new ZX_QualityChange();
            info.ID = FromInfo.ID;
            info.detailInfo = FromInfo.detailInfo;
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAccount().QualityChangeUpdate(info);
            else
            {
                SerFac.GetAccount().QualityChangeInsert(info);
                info = SerFac.GetAccount().QualityChangeSelect();
            }
            return View("QualityChange", info);
        }

        #endregion

        #region 培训系列图片列表
        
        /// <summary>
        /// 培训系列图片列表
        /// </summary>
        /// <returns></returns>
        public ActionResult TrainList()
        {
            IList<ZX_TrainList> Homelist;
            int hp_id = 0;
            ZX_TrainList HomePI = new ZX_TrainList();
            try
            {
                string actionstr = Request.QueryString["action"] == null ? "" : Request.QueryString["action"].ToString();
                hp_id = Request.QueryString["hp_id"] == null ? 0 : Convert.ToInt32(Request.QueryString["hp_id"]);
                if (actionstr == "del")
                {
                    SerFac.GetAboutService().DeleteTrainListById(hp_id);
                }
                else if (actionstr != "")
                {
                    HomePI = SerFac.GetAboutService().GetTrainListById(hp_id);
                    if (HomePI == null)
                    {
                        HomePI = new ZX_TrainList();
                        HomePI.ID = 0;
                        HomePI.trainName = "";
                        HomePI.trainImage = "";
                        HomePI.trainDetail = "";
                        HomePI.addUserID = 0;
                        HomePI.addTime = "";
                        HomePI.updateTime = "";
                    }
                }
            }
            catch (Exception)
            { }

            Homelist = SerFac.GetAboutService().GetTrainList();
            ViewData["Account_TrainList"] = Homelist;
            return View("TrainList", HomePI);
        }

        /// <summary>
        /// 培训系列图片列表 添加编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult TrainList_Edit(ZX_TrainList FromInfo)
        {
            ZX_TrainList HomePI = new ZX_TrainList();
            HomePI.ID = FromInfo.ID;
            HomePI.trainName = FromInfo.trainName;
            string Pic_Path = "";
            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file = Request.Files[0];
                Pic_Path = comm.UpLoadPic(file);
            }
            HomePI.trainImage = Pic_Path;
            HomePI.trainDetail = FromInfo.trainDetail;
            HomePI.addUserID = FromInfo.addUserID;
            HomePI.addTime = DateTime.Now.ToString();
            HomePI.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAboutService().UpdateTrainList(HomePI);
            else
                SerFac.GetAboutService().InsertTrainList(HomePI);
            return TrainList();
        }        

        #endregion

        #region 培训信息
        /// <summary>
        /// 培训信息
        /// </summary>
        /// <returns></returns>
        public ActionResult TrainInfo()
        {
            ZX_TrainInfo traininfo = SerFac.GetAccount().TrainInfoSelect();
            return View("TrainInfo",traininfo);
        }
        [HttpPost]
        public ActionResult TrainInfo_Edit(ZX_TrainInfo FromInfo)
        {
            ZX_TrainInfo info = new ZX_TrainInfo();
            info.ID = FromInfo.ID;
            info.trainInfo = FromInfo.trainInfo;
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAccount().TrainInfoUpdate(info);
            else
            {
                SerFac.GetAccount().TrainInfoInsert(info);
                info = SerFac.GetAccount().TrainInfoSelect();
            }
            return View("TrainInfo", info);
        }
        #endregion

        #region 经营理念
        /// <summary>
        /// 经营理念
        /// </summary>
        /// <returns></returns>
        public ActionResult News_Class()
        {
            ZX_Serprocess runidea = SerFac.GetAccount().SerprocessSelect();
            return View("News_Class", runidea);
        }
        [HttpPost]
        public ActionResult News_Class_Edit(ZX_Serprocess FromInfo)
        {
            ZX_Serprocess info = new ZX_Serprocess();
            info.ID = FromInfo.ID;
            info.Serprocess = FromInfo.Serprocess;
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAccount().SerprocessUpdate(info);
            else
            {
                SerFac.GetAccount().SerprocessInsert(info);
                info = SerFac.GetAccount().SerprocessSelect();
            }
            return View("News_Class", info);

        }
        #endregion

        #region 信息技术
        /// <summary>
        /// 信息技术
        /// </summary>
        /// <returns></returns>
        public ActionResult InfoSkill()
        {
            ZX_InfoSkill infoskill = SerFac.GetAccount().InfoSkillSelect();
            return View("InfoSkill",infoskill);
        }

        [HttpPost]
        public ActionResult InfoSkill_Edit(ZX_InfoSkill FromInfo)
        {
            ZX_InfoSkill info = new ZX_InfoSkill();
            info.ID = FromInfo.ID;
            info.skillInfo = FromInfo.skillInfo;
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAccount().InfoSkillUpdate(info);
            else
            {
                SerFac.GetAccount().InfoSkillInsert(info);
                info = SerFac.GetAccount().InfoSkillSelect();
            }
            return View("InfoSkill", info);
        }
        #endregion

        #region 公司新闻        
        /// <summary>
        /// 公司新闻
        /// </summary>
        /// <returns></returns>
        public ActionResult News()
        {
            IList<ZX_News> Homelist;
            int hp_id = 0;
            ZX_News HomePI = new ZX_News();
            try
            {
                hp_id = Request.QueryString["hp_id"] == null ? 0 : Convert.ToInt32(Request.QueryString["hp_id"]);
                Homelist = SerFac.GetAboutService().GetNewsById(hp_id);
                if (Homelist == null || Homelist.Count < 1)
                {
                    HomePI.ID = 0;
                    HomePI.title = "";
                    HomePI.detail = "";
                    HomePI.newsDate = "";
                    HomePI.addUserID = 0;
                    HomePI.addTime = "";
                    HomePI.updateTime = "";
                }
                else
                {
                    HomePI = Homelist[0];
                }
                string actionstr = Request.QueryString["action"] == null ? "" : Request.QueryString["action"].ToString();
                if (actionstr == "del")
                {
                    SerFac.GetAboutService().DeleteNewsById(hp_id);
                }
            }
            catch (Exception)
            { }

            Homelist = SerFac.GetAboutService().GetNews();
            ViewData["Account_ExpertType"] = Homelist;
            return View("News", HomePI);
        }

        /// <summary>
        /// 专家团队分类 添加编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult News_Edit(ZX_News FromInfo)
        {
            ZX_News HomePI = new ZX_News();
            HomePI.ID = FromInfo.ID;
            HomePI.title = FromInfo.title;
            HomePI.detail = FromInfo.detail;
            HomePI.newsDate = FromInfo.newsDate;
            HomePI.addUserID = FromInfo.addUserID;
            HomePI.addTime = DateTime.Now.ToString();
            HomePI.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAboutService().UpdateNews(HomePI);
            else
                SerFac.GetAboutService().InsertNews(HomePI);
            return News();
        }
        #endregion

        #region 公司观点
        /// <summary>
        /// 公司观点
        /// </summary>
        /// <returns></returns>
        public ActionResult CompanyPoint()
        {
            IList<ZX_CompanyPoint> Homelist;
            int hp_id = 0;
            ZX_CompanyPoint HomePI = new ZX_CompanyPoint();
            try
            {
                hp_id = Request.QueryString["hp_id"] == null ? 0 : Convert.ToInt32(Request.QueryString["hp_id"]);
                Homelist = SerFac.GetAboutService().GetCompanyPointById(hp_id);
                if (Homelist == null || Homelist.Count < 1)
                {
                    HomePI.ID = 0;
                    HomePI.title ="";
                    HomePI.detail = "";
                    HomePI.articleDate = "";
                    HomePI.addUserID = 0;
                    HomePI.addTime = "";
                    HomePI.updateTime = "";
                }
                else
                {
                    HomePI = Homelist[0];
                }
                string actionstr = Request.QueryString["action"] == null ? "" : Request.QueryString["action"].ToString();
                if (actionstr == "del")
                {
                    SerFac.GetAboutService().DeleteCompanyPointById(hp_id);
                }
            }
            catch (Exception)
            { }

            Homelist = SerFac.GetAboutService().GetCompanyPoint();
            ViewData["Account_ExpertType"] = Homelist;
            return View("CompanyPoint", HomePI);
        }
        /// <summary>
        /// 专家团队分类 添加编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult CompanyPoint_Edit(ZX_CompanyPoint FromInfo)
        {
            ZX_CompanyPoint HomePI = new ZX_CompanyPoint();
            HomePI.ID = FromInfo.ID;
            HomePI.title = FromInfo.title;
            HomePI.detail = FromInfo.detail;
            HomePI.articleDate = FromInfo.articleDate;
            HomePI.addUserID = FromInfo.addUserID;
            HomePI.addTime = DateTime.Now.ToString();
            HomePI.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAboutService().UpdateCompanyPoint(HomePI);
            else
                SerFac.GetAboutService().InsertCompanyPoint(HomePI);
            return CompanyPoint();
        }

        #endregion

        #region 联系方式
        /// <summary>
        /// 联系方式
        /// </summary>
        /// <returns></returns>
        public ActionResult CompanyContact()
        {
            ZX_CompanyContact comp = SerFac.GetAccount().CompanyContactSelect();
            return View("CompanyContact", comp);
        }

        [HttpPost]
        public ActionResult CompanyContact_Edit(ZX_CompanyContact FromInfo)
        {
            ZX_CompanyContact info = new ZX_CompanyContact();
            info.ID = FromInfo.ID;
            if (FromInfo.contactType == null) FromInfo.contactType = "";
            info.contactType = FromInfo.contactType;
            if (FromInfo.xy == null) FromInfo.xy = "";
            info.xy = "暂停使用";
            info.addUserID = FromInfo.addUserID;
            info.addTime = DateTime.Now.ToString();
            info.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAccount().CompanyContactUpdate(info);
            else
            {
                SerFac.GetAccount().CompanyContactInsert(info);
                info = SerFac.GetAccount().CompanyContactSelect();
            }
            return View("CompanyContact", info);
        }
        #endregion

        #region 在线留言
        
        /// <summary>
        /// 在线留言
        /// </summary>
        /// <returns></returns>
        public ActionResult LeaveMassage()
        {
            IList<ZX_LeaveMassage> Homelist;
            int hp_id = 0;
            ZX_LeaveMassage HomePI = new ZX_LeaveMassage();
            try
            {
                hp_id = Request.QueryString["hp_id"] == null ? 0 : Convert.ToInt32(Request.QueryString["hp_id"]);
                Homelist = SerFac.GetAboutService().GetLeaveMassageById(hp_id);
                if (Homelist == null || Homelist.Count < 1)
                {
                    HomePI.ID = 0;
                    HomePI.lname = "";
                    HomePI.contact = "";
                    HomePI.companyName = "";
                    HomePI.message = "";
                    HomePI.isRead = "";
                    HomePI.addTime = "";
                    HomePI.updateTime = "";
                }
                else
                {
                    HomePI = Homelist[0];
                }
                string actionstr = Request.QueryString["action"] == null ? "" : Request.QueryString["action"].ToString();
                if (actionstr == "del")
                {
                    SerFac.GetAboutService().DeleteCompanyPointById(hp_id);
                }
            }
            catch (Exception)
            { }

            Homelist = SerFac.GetAboutService().GetLeaveMassage();
            ViewData["Account_ExpertType"] = Homelist;
            return View("LeaveMassage", HomePI);
        }
        /// <summary>
        /// 在线留言 添加编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult LeaveMassage_Edit(ZX_LeaveMassage FromInfo)
        {
            ZX_LeaveMassage HomePI = new ZX_LeaveMassage();
            HomePI.ID = FromInfo.ID;
            //HomePI.lname = FromInfo.lname;
            //HomePI.contact = FromInfo.contact;
            //HomePI.companyName = FromInfo.companyName;
            //HomePI.message = FromInfo.message;
            HomePI.isRead = "1";
            HomePI.addTime = DateTime.Now.ToString();
            HomePI.updateTime = DateTime.Now.ToString();
            if (FromInfo.ID > 0)
                SerFac.GetAboutService().UpdateLeaveMassage(HomePI);
            else
                SerFac.GetAboutService().InsertLeaveMassage(HomePI);
            return LeaveMassage();
        }
        #endregion

        #region 关键字
        /// <summary>
        /// SEO
        /// </summary>
        /// <returns></returns>
        public ActionResult SEO()
        {
            ZX_SEO seo = SerFac.GetAccount().SEOSelect();
            return View("SEO",seo);
        }
        [HttpPost]
        public ActionResult SEO_Edit(ZX_SEO FromInfo)
        {
            ZX_SEO info = new ZX_SEO();
            info.ID = FromInfo.ID;
            info.keywords = FromInfo.keywords;
            info.description = FromInfo.description;
            info.author = "";
            SerFac.GetAccount().SEOInsert(info);
            info = SerFac.GetAccount().SEOSelect();
            return View("SEO", info);
        }
        #endregion

        [HttpPost]
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (MembershipService.ValidateUser(model.UserName, model.Password))
                {
                    FormsService.SignIn(model.UserName, model.RememberMe);
                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "提供的用户名或密码不正确。");
                }
            }

            // 如果我们进行到这一步时某个地方出错，则重新显示表单
            return View(model);
        }

        // **************************************
        // URL: /Account/LogOff
        // **************************************

        public ActionResult LogOff()
        {
            FormsService.SignOut();

            return RedirectToAction("Index", "Home");
        }

        // **************************************
        // URL: /Account/Register
        // **************************************

        public ActionResult Register()
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
            return View();
        }

        [HttpPost]
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // 尝试注册用户
                MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsService.SignIn(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                }
            }

            // 如果我们进行到这一步时某个地方出错，则重新显示表单
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
            return View(model);
        }


        // **************************************
        // URL: /Account/ChangePassword
        // **************************************
        [Authorize]
        public ActionResult ChangePassword()
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                if (MembershipService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword))
                {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                else
                {
                    ModelState.AddModelError("", "当前密码不正确或新密码无效。");
                }
            }

            // 如果我们进行到这一步时某个地方出错，则重新显示表单
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
            return View(model);
        }

        public ActionResult ChangePasswordSuccess()
        {
            return View();
        }

        #region 图片上传
        public ActionResult UploadImg()
        {
            List<string> Imglist = new List<string>();
            //****获取创建的DataTabel结构  
            Imglist = comm.GetImgList();
            ViewData["imgList"] = Imglist;
            return View();
        }

        public ActionResult UploadImg_Del(string ImgName)
        {
            bool Dbool = comm.Img_del(ImgName);
            return RedirectToAction("UploadImg", "Account");
        }
        public ActionResult UploadImg_Add()
        {
            string Pic_Path = "";
            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file = Request.Files[0];
                comm.UpLoadPic(file);
            }
            return RedirectToAction("UploadImg", "Account");
        }
        
        #endregion


        //HomePageImage	首页图片表
        //CompanyInfo	公司介绍
        //RunIdea	经营理念
        //ManagerSpeak	总经理致辞
        //ExpertType	专家团队分类
        //ExpertInfo	专家团队信息
        //WholeInfo	整体image
        //WholeInfoStrategy	整体战略
        //Product	精益生产
        //QualityChange	品质改善
        //TrainList	培训系列图片列表
        //TrainInfo	培训信息
        //InfoSkill	信息技术
        //News	公司新闻
        //CompanyPoint	公司观点
        //CompanyContact	联系方式
        //LeaveMassage	在线留言
        //SEO	SEO
    }
}
